package com.cn.sys.controller;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.sys.entity.SysLogEntity;
import com.cn.sys.service.SysLogService;
import com.cn.utils.FormSubmitResult;
import com.cn.utils.PageUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 系统日志
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController {
	@Autowired
	private SysLogService sysLogService;
	
	/**
	 * 列表
	 */
	@ResponseBody
	@RequestMapping("/list")
	//@RequiresPermissions("sys:log:list")
	public FormSubmitResult list(@RequestParam Map<String, Object> params){
		//查询列表数据
		Map query = new HashMap();
		query.put("username", params.get("username"));
		List<SysLogEntity> sysLogList = sysLogService.queryList(query);
		int total = sysLogService.queryTotal(query);
		System.out.println(query.get("username"));
		PageUtils pageUtil = new PageUtils(sysLogList, total, 20, 1);
		
		return FormSubmitResult.SUCCESS().put("page", pageUtil);
	}
	
	@RequestMapping(value = "/index",method = RequestMethod.GET)
    public String hello(Model model,HttpServletRequest request, HttpServletResponse response) {
        return "log/log";
    }
	
	@ResponseBody
	@RequestMapping(value = "/save")
    public FormSubmitResult save(@RequestBody SysLogEntity log) {
		System.out.println(log.getUsername());
        return  FormSubmitResult.SUCCESS();
    }
	
	
	
}
